package com.cslc.mp.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;

import com.cslc.mp.dao.DAO.IFaultDAO;
import com.cslc.mp.dao.vo.Fault;

public class FaultDAOImpl implements IFaultDAO{
	
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	public FaultDAOImpl(Connection conn) {
		this.conn = conn;
	}
	@Override
	public boolean doCreate(Fault fault) throws Exception {
    	String sql = "INSERT INTO fault(openid,content,pic,createdTime) VALUES(?,?,?,?)";  
        pstmt = conn.prepareStatement(sql);  
        pstmt.setString(1,fault.getOpenid());  
        pstmt.setString(2,fault.getContent());  
        pstmt.setString(3,fault.getPicId());  
        pstmt.setInt(4,fault.getCreateTime());  
        int update = pstmt.executeUpdate();  
	        if(update>0){  
	            return true;  
	        }  
	        else{  
	            return false;  
	        }  
	}
	
}
